package com.javer.dao.support;

import java.sql.ResultSet;
import java.sql.SQLException;

public final class ResultUtils {

	public static Object getObject(ResultSet rs, String name) {
		try {
			return rs.getObject(name);
		} catch (SQLException e) {
			return null;
		}
	}
	
	public static String getString(ResultSet rs, String name) {
		return String.valueOf(getObject(rs, name));
	}
	
	public static int getInt(ResultSet rs, String name) {
		try {
			return Integer.valueOf(getString(rs, name));
		} catch (NumberFormatException e) {
			return 0;
		}
	}
	
	public static long getLong(ResultSet rs, String name) {
		try {
			return Long.valueOf(getString(rs, name));
		} catch (NumberFormatException e) {
			return 0;
		}
	}
	
	public static double getDouble(ResultSet rs, String name) {
		try {
			return Double.valueOf(getString(rs, name));
		} catch (NumberFormatException e) {
			return 0;
		}
	}
	
}
